using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;

namespace VSSDKAssist.Deployment
{
	public class CreateProjectReferenceDefineConstants : Task
	{
		private ITaskItem[] defineConstants;

		[Output]
		public ITaskItem[] DefineConstants
		{
			get
			{
				return this.defineConstants;
			}
		}
		
		private ITaskItem[] projectReferencePaths;

		[Required]
		public ITaskItem[] ProjectReferencePaths
		{
			get
			{
				return this.projectReferencePaths;
			}
			set
			{
				this.projectReferencePaths = value;
			}
		}

		public override bool Execute()
		{
			List<ITaskItem> list = new List<ITaskItem>();
			foreach(ITaskItem item in this.ProjectReferencePaths)
			{
				string metadata = item.GetMetadata("Configuration");
				string str2 = item.GetMetadata("FullConfiguration");
				string str3 = item.GetMetadata("Platform");
				string path = item.GetMetadata("MSBuildSourceProjectFileFullPath");
				string str5 = Path.GetDirectoryName(path) + Path.DirectorySeparatorChar;
				string extension = Path.GetExtension(path);
				string fileName = Path.GetFileName(path);
				string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(path);
				string str9 = item.GetMetadata("FullPath");
				string str10 = Path.GetDirectoryName(str9) + Path.DirectorySeparatorChar;
				string str11 = Path.GetExtension(str9);
				string str12 = Path.GetFileName(str9);
				string str13 = Path.GetFileNameWithoutExtension(str9);
				list.Add(new TaskItem(string.Format(CultureInfo.CurrentCulture, "{0}.TargetDir={1}", new object[] { fileNameWithoutExtension, str10 })));
			}
			this.defineConstants = list.ToArray();

			return true;
		}
	}
}